package Server;

import java.awt.*;
import javax.swing.*;

/**
 * Creates the Server GUI
 * @author Jason Sorbello
 */
public class ServerGUI extends JFrame {

    private static boolean running = false;

    public static void setRunning(boolean running) {
        ServerGUI.running = running;
    }

    public static void appendText(String text) {
        ServerGUI.text.append(text);
    }

    public static boolean isRunning() {
        return running;
    }
    private static JTextArea text;

    public ServerGUI() {}
    public ServerGUI(String name) {}

    public void go() {
        final int TEXT_X = 20;
        final int TEXT_Y = 20;

        ServerGUI frame = new ServerGUI("Flight Server");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Container pane = frame.getContentPane();
        JPanel textPanel = new JPanel();
        JPanel buttons = new JPanel();

        JButton startBtn = new JButton("Start");
        JButton exitBtn = new JButton("Exit");

        buttons.add(startBtn);
        buttons.add(exitBtn);
        startBtn.addActionListener(new StartServerButton());
        exitBtn.addActionListener(new StopServerButton());

        text = new JTextArea(TEXT_X, TEXT_Y);
        text.setEditable(false);
        text.setLineWrap(true);
        JScrollPane textScroller = new JScrollPane(text);
        textPanel.add(textScroller);

        pane.add(textPanel, BorderLayout.SOUTH);
        pane.add(buttons, BorderLayout.NORTH);

        frame.pack();
        frame.setVisible(true);
    }
    public static void main(String[] args) {
        ServerGUI sg1 = new ServerGUI();
        sg1.go();
    }
}
